package com.shanshan.system.service.impl;

import com.shanshan.system.mapper.EchartsMapper;
import com.shanshan.system.service.EchartsService;
import com.shanshan.system.vo.EchartsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author keluoyisi
 * @program: shanshan
 * @description:
 * @date 2023-02-14 20:13:47
 */
@Service
@SuppressWarnings("all")
public class EchartsServiceImpl implements EchartsService {
    @Autowired
    private EchartsMapper echartsMapper;
    @Override
    public List<Map<String,Object>> getRecord() {
        List<Map<String, Object>> record = echartsMapper.getRecord();
        System.out.println(record);
        return record;
    }

    @Override
    public Map<String, List> getBranch() {
        List<EchartsVo> getbranch = echartsMapper.getbranch();

        Map<String, List> map = new HashMap<>();
        List<Object> list1 = new ArrayList<>();
        List<Object> list2 = new ArrayList<>();
        for (EchartsVo echartsVo : getbranch) {
            list1.add(echartsVo.getName());
            list2.add(echartsVo.getTotal());
        }
        map.put("name",list1);
        map.put("total",list2);
        return map;
    }
}
